package com.zxq.ai.domain.activity.strategy;

import com.zxq.ai.domain.user.User;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class IndependentCompletionStrategy implements CompletionStrategy {
    private Map<String, Boolean> completionStatus;

    public IndependentCompletionStrategy() {
        this.completionStatus = new HashMap<>();
    }

    public void markCompleted(String userId) {
        completionStatus.put(userId, true);
    }

    @Override
    public boolean isUserCompleted(String userId) {
        return completionStatus.getOrDefault(userId, false);
    }

    @Override
    public boolean isCompleted(List<User> participants) {
        for (User user : participants) {
            if (!completionStatus.getOrDefault(user.getUserId(), false)) {
                return false;
            }
        }
        return true;
    }
}